home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 32
/
Mac Magazin and MacEasy Magazine CD - Issue 32.iso
/
Multimedia
/
MIDI
/
MidiChaos_15 Folder
/
MidiChaos_1.5
/
Source
/
FP_Linear_Scaler
< prev
next >
Wrap
Text File
|
1992-04-24
|
2KB
|
114 lines
\ This class allows simple linear scaling of an FP number.
\
\ Author: Darren Gibbs Copyright 1990
\ Date: 4/9/90
\
\ MOD: RDG 4/21/90 Added support for concurrent multiple scaling using structs.
\ MOD: RDG 9/19/90 Cleaned up naming conventions.
\ MOD: RDG 9/29/90 Made into an object, 86'ed the struct's.
\ MOD: RDG 10/1/90 Use FP Ivars.
ANEW TASK-FP_LINEAR_SCALER
FPINIT
\ Setup floating point instance variables
: IV.FLPT ( <name> -- )
10 create.ivar
;
METHOD PUT.YHI: METHOD PUT.YLOW:
METHOD GET.YHI: METHOD GET.YLOW:
METHOD PUT.XHI: METHOD PUT.XLOW:
METHOD GET.XHI: METHOD GET.XLOW:
METHOD CALC.SLOPE:
METHOD SCALE>INT:
:CLASS OB.FP_LINEAR_SCALER <SUPER OBJECT
IV.FLPT IV-XLOW
IV.FLPT IV-XHI
IV.FLPT IV-YLOW
IV.FLPT IV-YHI
IV.FLPT IV-SLOPE
:M CALC.SLOPE: ( -- ) ( -- , calculate and store new slope )
\ slope = (Ylow - Yhi) / (Xlow - Xhi)
iv-yhi iv-ylow F-
iv-xhi iv-xlow F-
F/ iv=> iv-slope
;M
:M PUT.XLOW: ( -- ) ( n -- )
iv=> iv-xlow
calc.slope: self
;M
:M GET.XLOW: ( -- ) ( -- n )
iv-xlow
;M
:M PUT.XHI: ( -- ) ( n -- )
iv=> iv-xhi
calc.slope: self
;M
:M GET.XHI: ( -- ) ( -- n )
iv-xhi
;M
:M PUT.YLOW: ( -- ) ( n -- )
iv=> iv-ylow
calc.slope: self
;M
:M GET.YLOW: ( -- ) ( -- n )
iv-ylow
;M
:M PUT.YHI: ( -- ) ( n -- )
iv=> iv-yhi
calc.slope: self
;M
:M GET.YHI: ( -- ) ( -- n )
iv-yhi
;M
:M STUFF: ( -- ) ( xlow xhi ylow yhi -- )
iv=> iv-yhi iv=> iv-ylow
iv=> iv-xhi iv=> iv-xlow
calc.slope: self
;M
:M SCALE: ( -- ) ( n -- n' , scale n )
\ n' = n * slope + Ylow
iv-slope F*
iv-ylow F+
;M
:M SCALE>INT: ( -- n' ) ( n -- )
scale: self F>I
;M
TEXTROM SCALING-LABLES
," XLOW: " ," XHI: "
," YLOW: " ," YHI: "
," SLOPE: "
:M PRINT: ( -- )
cr name: self cr
0 scaling-lables type
iv-xlow f. cr
1 scaling-lables type
iv-xhi f. cr
2 scaling-lables type
iv-ylow f. cr
3 scaling-lables type
iv-yhi f. cr
4 scaling-lables type
iv-slope f. cr
;M
;CLASS